{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nexport function file2Obj(file) {\n  return Object.assign(Object.assign({}, file), {\n    lastModified: file.lastModified,\n    lastModifiedDate: file.lastModifiedDate,\n    name: file.name,\n    size: file.size,\n    type: file.type,\n    uid: file.uid,\n    percent: 0,\n    originFileObj: file\n  });\n}\n/** Upload fileList. Replace file if exist or just push into it. */\nexport function updateFileList(file, fileList) {\n  var nextFileList = _toConsumableArray(fileList);\n  var fileIndex = nextFileList.findIndex(function (_ref) {\n    var uid = _ref.uid;\n    return uid === file.uid;\n  });\n  if (fileIndex === -1) {\n    nextFileList.push(file);\n  } else {\n    nextFileList[fileIndex] = file;\n  }\n  return nextFileList;\n}\nexport function getFileItem(file, fileList) {\n  var matchKey = file.uid !== undefined ? 'uid' : 'name';\n  return fileList.filter(function (item) {\n    return item[matchKey] === file[matchKey];\n  })[0];\n}\nexport function removeFileItem(file, fileList) {\n  var matchKey = file.uid !== undefined ? 'uid' : 'name';\n  var removed = fileList.filter(function (item) {\n    return item[matchKey] !== file[matchKey];\n  });\n  if (removed.length === fileList.length) {\n    return null;\n  }\n  return removed;\n}\n// ==================== Default Image Preview ====================\nvar extname = function extname() {\n  var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n  var temp = url.split('/');\n  var filename = temp[temp.length - 1];\n  var filenameWithoutSuffix = filename.split(/#|\\?/)[0];\n  return (/\\.[^./\\\\]*$/.exec(filenameWithoutSuffix) || [''])[0];\n};\nvar isImageFileType = function isImageFileType(type) {\n  return type.indexOf('image/') === 0;\n};\nexport var isImageUrl = function isImageUrl(file) {\n  if (file.type && !file.thumbUrl) {\n    return isImageFileType(file.type);\n  }\n  var url = file.thumbUrl || file.url || '';\n  var extension = extname(url);\n  if (/^data:image\\//.test(url) || /(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico|heic|heif)$/i.test(extension)) {\n    return true;\n  }\n  if (/^data:/.test(url)) {\n    // other file types of base64\n    return false;\n  }\n  if (extension) {\n    // other file types which have extension\n    return false;\n  }\n  return true;\n};\nvar MEASURE_SIZE = 200;\nexport function previewImage(file) {\n  return new Promise(function (resolve) {\n    if (!file.type || !isImageFileType(file.type)) {\n      resolve('');\n      return;\n    }\n    var canvas = document.createElement('canvas');\n    canvas.width = MEASURE_SIZE;\n    canvas.height = MEASURE_SIZE;\n    canvas.style.cssText = \"position: fixed; left: 0; top: 0; width: \".concat(MEASURE_SIZE, \"px; height: \").concat(MEASURE_SIZE, \"px; z-index: 9999; display: none;\");\n    document.body.appendChild(canvas);\n    var ctx = canvas.getContext('2d');\n    var img = new Image();\n    img.onload = function () {\n      var width = img.width,\n        height = img.height;\n      var drawWidth = MEASURE_SIZE;\n      var drawHeight = MEASURE_SIZE;\n      var offsetX = 0;\n      var offsetY = 0;\n      if (width > height) {\n        drawHeight = height * (MEASURE_SIZE / width);\n        offsetY = -(drawHeight - drawWidth) / 2;\n      } else {\n        drawWidth = width * (MEASURE_SIZE / height);\n        offsetX = -(drawWidth - drawHeight) / 2;\n      }\n      ctx.drawImage(img, offsetX, offsetY, drawWidth, drawHeight);\n      var dataURL = canvas.toDataURL();\n      document.body.removeChild(canvas);\n      resolve(dataURL);\n    };\n    img.crossOrigin = 'anonymous';\n    if (file.type.startsWith('image/svg+xml')) {\n      var reader = new FileReader();\n      reader.addEventListener('load', function () {\n        if (reader.result) img.src = reader.result;\n      });\n      reader.readAsDataURL(file);\n    } else {\n      img.src = window.URL.createObjectURL(file);\n    }\n  });\n}","map":{"version":3,"names":["_toConsumableArray","file2Obj","file","Object","assign","lastModified","lastModifiedDate","name","size","type","uid","percent","originFileObj","updateFileList","fileList","nextFileList","fileIndex","findIndex","_ref","push","getFileItem","matchKey","undefined","filter","item","removeFileItem","removed","length","extname","url","arguments","temp","split","filename","filenameWithoutSuffix","exec","isImageFileType","indexOf","isImageUrl","thumbUrl","extension","test","MEASURE_SIZE","previewImage","Promise","resolve","canvas","document","createElement","width","height","style","cssText","body","appendChild","ctx","getContext","img","Image","onload","drawWidth","drawHeight","offsetX","offsetY","drawImage","dataURL","toDataURL","removeChild","crossOrigin","startsWith","reader","FileReader","addEventListener","result","src","readAsDataURL","window","URL","createObjectURL"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/antd/es/upload/utils.js"],"sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nexport function file2Obj(file) {\n  return Object.assign(Object.assign({}, file), {\n    lastModified: file.lastModified,\n    lastModifiedDate: file.lastModifiedDate,\n    name: file.name,\n    size: file.size,\n    type: file.type,\n    uid: file.uid,\n    percent: 0,\n    originFileObj: file\n  });\n}\n/** Upload fileList. Replace file if exist or just push into it. */\nexport function updateFileList(file, fileList) {\n  const nextFileList = _toConsumableArray(fileList);\n  const fileIndex = nextFileList.findIndex(_ref => {\n    let {\n      uid\n    } = _ref;\n    return uid === file.uid;\n  });\n  if (fileIndex === -1) {\n    nextFileList.push(file);\n  } else {\n    nextFileList[fileIndex] = file;\n  }\n  return nextFileList;\n}\nexport function getFileItem(file, fileList) {\n  const matchKey = file.uid !== undefined ? 'uid' : 'name';\n  return fileList.filter(item => item[matchKey] === file[matchKey])[0];\n}\nexport function removeFileItem(file, fileList) {\n  const matchKey = file.uid !== undefined ? 'uid' : 'name';\n  const removed = fileList.filter(item => item[matchKey] !== file[matchKey]);\n  if (removed.length === fileList.length) {\n    return null;\n  }\n  return removed;\n}\n// ==================== Default Image Preview ====================\nconst extname = function () {\n  let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n  const temp = url.split('/');\n  const filename = temp[temp.length - 1];\n  const filenameWithoutSuffix = filename.split(/#|\\?/)[0];\n  return (/\\.[^./\\\\]*$/.exec(filenameWithoutSuffix) || [''])[0];\n};\nconst isImageFileType = type => type.indexOf('image/') === 0;\nexport const isImageUrl = file => {\n  if (file.type && !file.thumbUrl) {\n    return isImageFileType(file.type);\n  }\n  const url = file.thumbUrl || file.url || '';\n  const extension = extname(url);\n  if (/^data:image\\//.test(url) || /(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico|heic|heif)$/i.test(extension)) {\n    return true;\n  }\n  if (/^data:/.test(url)) {\n    // other file types of base64\n    return false;\n  }\n  if (extension) {\n    // other file types which have extension\n    return false;\n  }\n  return true;\n};\nconst MEASURE_SIZE = 200;\nexport function previewImage(file) {\n  return new Promise(resolve => {\n    if (!file.type || !isImageFileType(file.type)) {\n      resolve('');\n      return;\n    }\n    const canvas = document.createElement('canvas');\n    canvas.width = MEASURE_SIZE;\n    canvas.height = MEASURE_SIZE;\n    canvas.style.cssText = `position: fixed; left: 0; top: 0; width: ${MEASURE_SIZE}px; height: ${MEASURE_SIZE}px; z-index: 9999; display: none;`;\n    document.body.appendChild(canvas);\n    const ctx = canvas.getContext('2d');\n    const img = new Image();\n    img.onload = () => {\n      const {\n        width,\n        height\n      } = img;\n      let drawWidth = MEASURE_SIZE;\n      let drawHeight = MEASURE_SIZE;\n      let offsetX = 0;\n      let offsetY = 0;\n      if (width > height) {\n        drawHeight = height * (MEASURE_SIZE / width);\n        offsetY = -(drawHeight - drawWidth) / 2;\n      } else {\n        drawWidth = width * (MEASURE_SIZE / height);\n        offsetX = -(drawWidth - drawHeight) / 2;\n      }\n      ctx.drawImage(img, offsetX, offsetY, drawWidth, drawHeight);\n      const dataURL = canvas.toDataURL();\n      document.body.removeChild(canvas);\n      resolve(dataURL);\n    };\n    img.crossOrigin = 'anonymous';\n    if (file.type.startsWith('image/svg+xml')) {\n      const reader = new FileReader();\n      reader.addEventListener('load', () => {\n        if (reader.result) img.src = reader.result;\n      });\n      reader.readAsDataURL(file);\n    } else {\n      img.src = window.URL.createObjectURL(file);\n    }\n  });\n}"],"mappings":"AAAA,OAAOA,kBAAkB,MAAM,8CAA8C;AAC7E,OAAO,SAASC,QAAQ,CAACC,IAAI,EAAE;EAC7B,OAAOC,MAAM,CAACC,MAAM,CAACD,MAAM,CAACC,MAAM,CAAC,CAAC,C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